<!DOCTYPE html>
<html>
<head>
	<title></title>
	<script type="text/javascript" src="https://cdn.staticfile.net/jquery/3.7.1/jquery.min.js"></script>
	<style type="text/css">
		*{
			padding:20px;
		}
		#box{
			width: 500px;
			height: auto;
			border:1px lightgray solid;
		}
	</style>
</head>
<body>
<div id="box">
	
</div>
<input type="text" placeholder="输入要发送的内容" id="message">
<input type="button" name="" value="发送" id="sub">
<script type="text/javascript">
    ws = new WebSocket("ws://117.72.89.204:2348");
    ws.onopen = function() {
        $("#box").append("连接成功<br />");
        
    };
    ws.onmessage = function(e) {
        $("#box").append(e.data + "<br />");
    };
    $("#sub").click(function(){
        let content = $("#message").val();
		$ajax_url = "/gacj/api/test.html";
        $.post($ajax_url, {content:content}, function(data) {
			console.log(data);
			if (data) {
				alert('发送成功')
			} else {
				alert('发送失败')
			}
		});
    });
</script>
</body>
</html>